<?php
/**
 * Created by PhpStorm.
 * User: changyifan
 * Date: 2018/3/2
 * Time: 下午2:47
 */

namespace Home\Model;
use Think\Model\BaseModel;

class AnnoucementModel extends BaseModel{


    protected $_link = array(
        'Teachingclass' => array(
            'mapping_type' => self::BELONGS_TO,
            'class_name' => 'Teachingclass',
            'foreign_key' => 'tc_id',
            'mapping_fields' => 'tc_name',
            'as_fields' => 'tc_name'
        ),
    );

    protected $_scope = array(
        'default' => array(
            'where' => array('tc_id' => ''),
            'field' => array('ann_id','ann_title','tc_id','ann_time'),
        ),

    );
    public function getAnnounceInfoListWithTcId($tc_id){

        if ($tc_id == 0){
            $tc_id = array('like','%%');
        }
        $result = $this-> scope('default',array('where'=>array('tc_id'=>$tc_id))) -> relation(true) -> select();
        if($result){
            return $result;
        }else{
            return array();
        }
    }
}